﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="scripts/jquery-1.9.1.min.js"></script>
    <link href="bootstrap2.3.2/css/bootstrap.min.css" rel="stylesheet" />
    <title></title>
    <link href="styles/Common.css" rel="stylesheet" />
    <link href="styles/Index.css" rel="stylesheet" />
	<link href="styles/Index2.css" rel="stylesheet" />

    <script type="text/javascript">
        $(function() {
            $("#tj").click(function () {
                $.ajax({
                    type: "post",
                    url: "user?method=update",
                    data: "repassword=" + $("#repassword").val(),
                    success: function (result) {
                        if (result == 1) {
                            alert("修改成功，请重新登录");
                            $.ajax({
                                url : "user?method=delete"
                            })
                            location.replace("http://localhost:8080/login.jsp");
                        } else {
                            alert("修改失败");
                            location.reload(true);
                        }
                    }
                })
            })
        });

        function checkOldPwd(){
            $.ajax({
                type:"post",
                url:"user?method=checkPwd",
                data:"oldPwd="+$("#oldPwd").val(),
                success:function (result) {
                    if (result == 1){
                        $("#info").text("OK").css("color","green");
                        $("#tj").removeClass("disabled");
                    }else {
                        $("#info").text("ERROR").css("color","red");
                        $("#tj").addClass("disabled");
                    }
                }
            })
        }


        $(function(){
            $("#repassword").change(function () {
                if ($("#password").val() == $("#repassword").val()){
                    $("#tj").removeAttr("disabled");
                    $("#info1").html("")
                }else {
                    $("#tj").attr("disabled",true);
                    $("#info1").html("两次密码不一致").css("color","red")
                }
            })

        })

    </script>
</head>
<body>
    <jsp:include page="header.jsp"/>


    <div class="nav">

        <ul class="breadcrumb">
            <li>
                <img src="images/32/5025_networking.png" />
            </li>
            <li><a href="index.jsp">首页</a> <span class="divider">>></span></li>
            <li class="active">修改密码</li>
        </ul>
    </div>



    <div class="container-fluid content">
        <div class="row-fluid">
            <div class="span2 content-left">
                <div class="accordion">
                    <div class="accordion-group">
                        <div class="accordion-heading">
                            <a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" href="#collapseOne">
                                <img class="left-icon" src="images/32/5026_settings.png" /><span class="left-title">系统设置</span>
                            </a>
                        </div>
                        <div id="collapseOne" class="accordion-body collapse in">
                            <div class="accordion-inner">
                                 <a href="list.jsp"> <img class="left-icon-child" src="images/32/4962_sitemap.png" /><span class="left-body"> 药品管理</span></a>
                            </div>

                            <div class="accordion-inner">
                              <a href="password.jsp">  <img class="left-icon-child" src="images/32/4992_user.png" /><span class="left-body"> 修改密码</span></a>

                            </div>
                            <div class="accordion-inner">
                              <a href="user?method=loginOut">  <img class="left-icon-child" src="images/32/4958_login.png" /><span class="left-body"> 退出登陆</span></a>

                            </div>
                        </div>
                    </div>
                </div>

            </div>


            <div class="span10 content-right">
               <div class="container-fluid">

                   <div class="row" style="padding-top:20px">

                        <div style="margin-left: 100px;margin-top: 20px">
                            <div class="control-group">
                                <label class="control-label" for="userName">原始密码</label>
                                <div class="controls">
                                    <input type="password" onchange="checkOldPwd()" id="oldPwd" placeholder="原始密码" name="oldPwd">
                                    <span id="info"></span>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="Chinese">新密码</label>
                                <div class="controls">
                                    <input type="password" id="password" placeholder="新密码" name="password">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="Math">确认密码</label>
                                <div class="controls">
                                    <input type="password" id="repassword" placeholder="确认密码" name="repassword">
                                    <span id="info1"></span>
                                </div>
                            </div>

                             <div class="control-group">
                               <div class="controls">
                                   <button type="submit" class="btn btn-success" id="tj" value="提交">提交</button>
                               </div>
                             </div>
                        </div>
                   </div>
               </div>
            </div>
        </div>
    </div>



    <div class="clearfix"></div>
    <div class="foot"></div>
    <script src="scripts/jquery-1.9.1.min.js"></script>
    <script src="bootstrap2.3.2/js/bootstrap.min.js"></script>
    <script src="scripts/Index.js"></script>
	<div style="text-align:center;">
<p>来源:<a href="http://www.mycodes.net/" target="_blank">源码之家</a></p>
</div>

</body>
</html>
